package com.yhp.config;

import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    //为静态资源提供网络映射服务
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**")
                .addResourceLocations("classpath:/META-INF/resources/")  //映射swagger2
               // .addResourceLocations("file:F:\\imooc\\");//映射本地静态资源
                .addResourceLocations("file:/usr/local/");//映射本地静态资源 这里映射的地址相当于是localhost:8088
        //有域名的时候，可以使用域名，将静态资源映射到服务中
        //映射后的图片访问地址：http://localhost:8088/uploadimg/2011187ATXCPWRGC/face-2011187ATXCPWRGC.png
        //实际图片存储地址   :   F:\\imooc\\uploadimg/2011187ATXCPWRGC/face-2011187ATXCPWRGC.png
    }

    @Bean
    public RestTemplate restTemplate(RestTemplateBuilder builder){
        return builder.build();
    }
}
